package com.ruoyi.web.wapper;

import cn.hutool.core.util.DesensitizedUtil;
import cn.hutool.core.util.ObjectUtil;
import com.ruoyi.common.enums.SmsOTypeEnum;
import com.ruoyi.common.wapper.BaseControllerWrapper;
import org.apache.commons.lang3.ObjectUtils;

import java.util.List;
import java.util.Map;

public class SmsRecordWapper extends BaseControllerWrapper {

    public SmsRecordWapper(Map<String, Object> single) {
        super(single);
    }

    public SmsRecordWapper(List<Map<String, Object>> multi) {
        super(multi);
    }

//    public AccountUserWrapper(Page<Map<String, Object>> page) {
//        super(page);
//    }
//
//    public AccountUserWrapper(PageResult<Map<String, Object>> pageResult) {
//        super(pageResult);
//    }

    @Override
    public void wrapTheMap(Map<String, Object> map) {

        try {

            Integer otype = (Integer) map.get("otype");
            if (ObjectUtils.isNotEmpty(otype)) {
                map.put("otypeStr", SmsOTypeEnum.getLabelByValue(otype));
            }

            String mobile = (String) map.get("mobile");
            if (ObjectUtils.isNotEmpty(mobile)) {
                map.put("mobileStr", DesensitizedUtil.mobilePhone(mobile));
            }

            Boolean isSuccess = (Boolean) map.get("issuccess");
            if (ObjectUtils.isNotEmpty(isSuccess)) {
                map.put("isSuccessStr", isSuccess?"成功":"失败");
            }

        }catch (Exception ex){
            ex.printStackTrace();
        }
    }
}
